<template>
  <div class="custom-tabs">
    <ul class="custom-tabs-list">
      <el-button
        v-for="(item, index) in tabs"
        :key="index"
        :type="item.key === currentKey ? 'primary' : ''"
        class="custom-tabs-item"
        @click="handleTabClick(item.key, item.value)"
      >
        <span>{{ item.label }}</span>
        <span v-if="isShowNum">({{ item.num || 0 }})</span>
      </el-button>
    </ul>
    <slot />
  </div>
</template>

<script>
export default {
  name: 'Tabs',
  props: {
    tabs: {
      type: Array,
      default: () => {
        return []
      }
    },
    currentKey: {
      type: String,
      default: ''
    },
    isShowNum: {
      type: Boolean,
      default: true
    }
  },
  methods: {
    handleTabClick(key, value) {
      this.$emit('tab-click', { key, value })
    }
  }
}
</script>

<style lang="scss" scoped>
.custom-tabs {
  display: flex;
  justify-content: space-between;
  margin: 20px 0;
  &-item {
    display: inline-block;
    cursor: pointer;
    margin: 0 10px 0 0;
    font-size: 14px;
  }
}
</style>
